package HomeWork;

public class test {
    public static void main(String[] args) {
        // 创建学生对象
        Student student = new Student(1, "JIA", 21, "计算机科学与技术");
        System.out.println(student.toString());

        // 创建学生管理服务
        Student_Manage_Service service = new Student_Manage_Service();

        // 测试添加学生
        System.out.println("\n=== 测试添加学生 ===");
        boolean addResult = service.addStudent(student);
        System.out.println("添加学生结果: " + (addResult ? "成功" : "失败"));

        // 添加更多学生用于测试
        service.addStudent(new Student(2, "李四", 20, "数学"));
        service.addStudent(new Student(3, "王五", 22, "物理"));

        // 测试查找所有学生
        System.out.println("\n=== 测试查找所有学生 ===");
        Student[] allStudents = service.findAllStudents();
        System.out.println("学生总数: " + allStudents.length);
        for (Student s : allStudents) {
            System.out.println(s.toString());
        }

        // 测试更新学生
        System.out.println("\n=== 测试更新学生 ===");
        Student updatedStudent = new Student(1, "JIA-更新", 23, "软件工程");
        boolean updateResult = service.updateStudent(updatedStudent);
        System.out.println("更新学生结果: " + (updateResult ? "成功" : "失败"));

        // 验证更新结果
        allStudents = service.findAllStudents();
        System.out.println("更新后的学生信息:");
        for (Student s : allStudents) {
            System.out.println(s.toString());
        }

        // 测试删除学生
        System.out.println("\n=== 测试删除学生 ===");
        boolean deleteResult = service.deleteStudent(2);
        System.out.println("删除学生结果: " + (deleteResult ? "成功" : "失败"));

        // 验证删除结果
        allStudents = service.findAllStudents();
        System.out.println("删除后的学生列表:");
        for (Student s : allStudents) {
            System.out.println(s.toString());
        }
    }
}
